package cn.lili.controller.feign;

import cn.lili.common.utils.StringUtils;
import cn.lili.modules.goods.client.GoodsClient;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
import cn.lili.modules.promotion.client.BlindboxCountClient;
import cn.lili.modules.promotion.client.BoxMhGoodsClient;
import cn.lili.modules.promotion.entity.dos.BoxMhgoods;
import cn.lili.modules.promotion.entity.dos.BoxMhgoodsTag;
import cn.lili.modules.promotion.entity.dto.CallbackBlindboxDTO;
import cn.lili.modules.promotion.service.BlindboxCountService;
import cn.lili.modules.promotion.service.BoxMhgoodsService;
import cn.lili.modules.promotion.service.BoxMhgoodsTagService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class BoxMhGoodsFeignController implements BoxMhGoodsClient {

    private final BoxMhgoodsService boxMhgoodsService;

    private final BoxMhgoodsTagService mhgoodsTagService;

    /**
     * 更新盲盒数据
     *
     * @param callbackBlindboxDTO 参数
     * @return
     */
    @Override
    public List<Goods> callbackMhGoods(CallbackBlindboxDTO callbackBlindboxDTO) {
        return boxMhgoodsService.callbackMhGoods(callbackBlindboxDTO);
    }

    /**
     * 将商品从盲盒中移除
     * @param mhId 盲盒
     * @param id 商品
     * @return 是否成功
     */
    @Override
    public Boolean removeGoodsMh(String mhId, String id) {
        return boxMhgoodsService.removeGoodsMh(mhId, id);
    }

    @Override
    public BoxMhgoods getById(String mhId) {
        return boxMhgoodsService.getById(mhId);
    }

    @Override
    public List<BoxMhgoods> getByIds(String mhIds) {
        return boxMhgoodsService.list(new LambdaQueryWrapper<BoxMhgoods>().in(BoxMhgoods::getId, (Object[]) mhIds.split(",")));
    }

    @Override
    public Long getBiZhongGoodsById(String id) {
        return boxMhgoodsService.count(new LambdaQueryWrapper<BoxMhgoods>().eq(BoxMhgoods::getBigGoodsId, id));
    }

    @Override
    public List<BoxMhgoodsTag> getTagListById(String mhId) {
        return mhgoodsTagService.list(new LambdaQueryWrapper<BoxMhgoodsTag>().eq(BoxMhgoodsTag::getMhgoodsId, mhId));
    }
}
